<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/common/jstl.jspf" %>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>用户信息管理</title>
	<style type="text/css">
		table {
			width: 100%;
			border-collapse: collapse;
		}

		th,td {
			padding: 10px;
			border: 1px solid #ccc;
			text-align: center;
		}
	</style>
	<script type="text/javascript" src="${baseUrl }/static/jquery/jquery.min.js"></script>
</head>
<body>
	${exception.message }
	<fieldset style="width:90%;">
		<legend>用户信息检索</legend>
			<form id="condition" action="${baseUrl }/emp/empAction_listEmp.action" method="post">
				<table>
					<tr>
						<th>编号:</th>
						<td><input type="text" name="emp.empId" value="${emp.empId }" /></td>
						<th>姓名:</th>
						<td><input type="text" name="emp.empName" value="${emp.empName }" /></td>
						<th>部门:</th>
						<td>
							<select name="emp.dept.deptId">
								<option value="">--请选择--</option>
								<c:forEach items="${depts}" var="dept">
									<option value="${dept.deptId }" ${emp.dept.deptId == dept.deptId ? "selected" : "" }>${dept.deptName }</option>
								</c:forEach>
							</select>
						</td>
						<td><input type="submit" value="检索" /></td>
					</tr>
				</table>
			</form>
	</fieldset>
	<fieldset style="width:90%;">
		<legend>用户信息列表[<a href="${baseUrl }/emp/empAction_initAdd.action">添加</a>]</legend>
		<table>
			<tr>
				<th>编号</th>
				<th>姓名</th>
				<th>性别</th>
				<th>入职时间</th>
				<th>部门</th>
				<th>操作</th>
			</tr>
			<c:if test="${fun:length(pageBean.list) == 0 }">
				<tr>
					<td colspan="5">
						<font size="+1" color="red">暂无操作的数据，请添加</font>
					</td>
				</tr>
			</c:if>
			<c:forEach items="${pageBean.list }" var="emp">
				<tr>
					<td>${emp.empId }</td>
					<td>${emp.empName }</td>
					<td>${emp.empSex }</td>
					<td><fmt:formatDate value="${emp.empHiredate }" pattern="yyyy-MM-dd"/></td>
					<td>${emp.dept.deptName }</td>
					<td>
						<a href="javascript:delectConfirm('1000');">删除</a> 
						|
						<a href="${baseUrl }/emp/empAction_initUpdate.action?emp.empId=${emp.empId }">修改</a>
						</td>
				</tr>
			</c:forEach>
			<tr>
				<td colspan="6" style="text-align: right;">
					总共${pageBean.totalRows }条记录 共${pageBean.totalPages }页 当前第${pageBean.currentPage}页
					<a href="javascript:pager('${pageBean.firstPage}');">首页</a>
					<a href="javascript:pager('${pageBean.previousPage}');">上一页</a>
					<a href="javascript:pager('${pageBean.nextPage}');">下一页</a>
					<a href="javascript:pager('${pageBean.lastPage}');">尾页</a>
				</td>
			</tr>
		</table>
	</fieldset>
	<script type="text/javascript">
		function delectConfirm(id) {
			if (confirm("确认删除吗?")) {
				location.href="${baseUrl }/emp/empAction_deleteEmp.action?emp.empId="+id;
			}
		}
		
		function pager(currentPage) {
			var condition = $("#condition").serialize();
			location.href="${baseUrl }/emp/empAction_listEmp.action?pageBean.currentPage="+currentPage+"&"+condition;
		}
	</script>
</body>
</html>